/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package deatax;

import java.io.InputStream;
import java.io.Reader;
import java.io.InputStreamReader;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;

/**
 *
 * @author Pieman
 */
public class ResourceLoader {

    public static InputStream loadStream(String s){
        return ResourceLoader.class.getResourceAsStream(s);
    }

    public static Reader loadReader(String resource){
        return new InputStreamReader(loadStream(resource));
    }

    public static boolean resourceExists(String resource){
        boolean b = ResourceLoader.class.getResourceAsStream(resource) != null;
        
        System.out.println(resource + " exists: " + b);
        return b;
    }

    public static URI loadResource(String s) {
        ClassLoader loader = ResourceLoader.class.getClassLoader();
        URL url = loader.getResource(s);
        try {
            return url.toURI();
        } catch (URISyntaxException ex) {
            ex.printStackTrace();
        }
        return null;
    }
}
